#include "AnimationUtil.h"

CCAnimation* AnimationUtil::createAnimationWithSingleFrameN(char* name,float delay,unsigned int iLoops){

	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();

	CCArray* frames = CCArray::create();

	CCSpriteFrame* frame = NULL;
	
	int index = 1;
	do{
		frame = cache->spriteFrameByName(CCString::createWithFormat("%s%d.png",name,index++)->getCString());

		if(frame == NULL){
			break;
		}

		frames->addObject(frame);

	}while(true);

	CCAnimation* animation = CCAnimation::createWithSpriteFrames(frames);
	animation->setLoops(iLoops);
	animation->setDelayPerUnit(delay);
	animation->setRestoreOriginalFrame(true);

	return animation;


}